package com.aso.common.utils;

import android.annotation.SuppressLint;
import android.app.Application;

/**
 * Utils初始化相关
 * Created by itsdf07 on 2017/7/14 10:55.
 * E-Mail: 923255742@qq.com
 * GitHub: https://github.com/itsdf07
 */
public final class Utils {

    @SuppressLint("StaticFieldLeak")
    private static Application application;

    private Utils() {
        throw new UnsupportedOperationException("u can't instantiate me...");
    }

    /**
     * 初始化工具类
     *
     * @param application 上下文
     */
    public static void init(Application application) {
        Utils.application = application;
    }

    /**
     * 获取ApplicationContext
     *
     * @return ApplicationContext
     */
    public static Application getApplication() {
        if (application != null) return application;
        throw new NullPointerException("u should init first");
    }
}